package org.structure.boot.demomybatis.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.structure.boot.demomybatis.entity.User;
import org.structure.boot.demomybatis.service.IUserService;

import javax.annotation.Resource;

/**
 * @version V1.0.0
 * @Title: UserController
 * @Package org.structure.boot.demomybatis.controller
 * @Description: ${TODO} 此类的用途
 * @author: chuck
 * @date: 2020/6/1 11:10
 */

@Controller
@RequestMapping("/user")
public class UserController {

    @Resource
    private IUserService iUserService;

    @GetMapping("/findUserById")
    @ResponseBody
    public User findUserById(@RequestParam("id") String id) {
        System.out.println("id = " + id);
        return iUserService.findById(id);
    }

    @PostMapping("/add")
    @ResponseBody
    public User add(@RequestBody User user) {
        iUserService.addUser(user);
        return user;
    }

}
